
version = 8.3.0
release = b9757d

source = https://cdn.change-vision.com/files/astah-professional_$(version).$(release)-0_all.deb

image_tag = astah-ui:latest


GO_DIR = ../src
BINARY_NAME = astah-ui
BINARY = $(GO_DIR)/$(BINARY_NAME)
GO_SOURCE = \
	$(GO_DIR)/go.mod $(GO_DIR)/go.sum \
	$(shell find $(GO_DIR) -type f -name '*.go') \
	$(NULL)



all: ../.dockerignore

cache/astah-professional_all.deb:
	mkdir -p cache
	curl "$(source)" > cache/astah-professional_all.deb

cache/usr/lib/astah_professional/astah-pro.jar: cache/astah-professional_all.deb
	cd cache; ar x astah-professional_all.deb; tar xf data.tar.gz
	touch cache/usr/lib/astah_professional/astah-pro.jar

# binary
$(BINARY): ./Makefile $(GO_SOURCE)
	cd $(GO_DIR); CGO_ENABLED=0 go build -ldflags "-s -w -X main.build=$$(date +%Y-%m-%d_%H:%M:%S).$$(git rev-parse HEAD)" -o $(BINARY_NAME) .

../.dockerignore: ./Dockerfile ./Makefile cache/usr/lib/astah_professional/astah-pro.jar $(BINARY)
	printf '*\n!/deploy/cache/usr\n!/src/astah-ui' >../.dockerignore ; docker build -f Dockerfile -t "$(image_tag)" ..

